package com.example.android.adsense;

import com.google.ads.AdSenseSpec;
import com.google.ads.AdSenseSpec.AdType;
import com.google.ads.GoogleAdView;

import android.app.Activity;
import android.os.Bundle;

public class AdSenseExample extends Activity {

    // Replace with your own AdSense client ID.
    private static final String CLIENT_ID = "ca-mb-app-pub-nnnnnnnnnnnnnnnn";

    // Replace with your own company name.
    private static final String COMPANY_NAME = "Company Name";

    // Replace with your own application name.
    private static final String APP_NAME = "App Name";

    // Replace with your own keywords used to target Google ad.
    // Join multiple words in a phrase with '+' and join multiple phrases with ','.
    private static final String KEYWORDS = "hotels+san+francisco";

    // Replace with your own AdSense channel ID.
    private static final String CHANNEL_ID = "6562723305";

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        // Set up GoogleAdView.
        GoogleAdView adView = (GoogleAdView) findViewById(R.id.adview);
        AdSenseSpec adSenseSpec =
            new AdSenseSpec(CLIENT_ID)     // Specify client ID. (Required)
            .setCompanyName(COMPANY_NAME)  // Set company name. (Required)
            .setAppName(APP_NAME)          // Set application name. (Required)
            .setKeywords(KEYWORDS)         // Specify keywords.
            .setChannel(CHANNEL_ID)        // Set channel ID.
            .setAdType(AdType.TEXT)        // Set ad type to Text.
            .setAdTestEnabled(true);       // Keep true while testing.

        // If application content is equivalent to an existing website URL then set:
        // adSenseSpec.setWebEquivalentUrl(url) to improve ad targeting.

        // Fetch Google ad.
        // PLEASE DO NOT CLICK ON THE AD UNLESS YOU ARE IN TEST MODE.
        // OTHERWISE, YOUR ACCOUNT MAY BE DISABLED.
        adView.showAds(adSenseSpec);
    }
}
